import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import UserManagement from '../components/UserManagement.vue'
import ChatWindow from '../components/ChatWindow.vue' // 新增导入
import Layout from "../layout/Layout.vue";

const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        name: 'Home',
        component: HomeView
      },
    ]
  },
    //登录
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login.vue')
  },
  //注册
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/Register.vue')
  },
  {
    path: '/user',
    name: 'user',
    component: UserManagement,
    meta: {
      requiresAuth: false // 根据你的安全需求调整
    }
  },
  // 新增聊天路由
  {
    path: '/chat',
    name: 'chat',
    component: ChatWindow,
    meta: {
      requiresAuth: false // 根据你的安全需求调整
    }
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router